<?php
session_start();

include('connect.inc');

// Passkey that got from link 
$passkey=$_GET['passkey'];

// Retrieve data from table where row that match this passkey 
$sql1="SELECT * FROM temp_members WHERE confirm_code ='$passkey'";
$result1=pg_query($sql1);

// If successfully queried 
if($result1)
{
	// Count how many row has this passkey
	$count=pg_num_rows($result1);

	// if found this passkey in database
	if($count==1)
	{
		$rows=pg_fetch_array($result1);
		$_SESSION['id'] = $rows['temp_member_id'];
		header('Location: create_database.php');
        exit();
	}

	// if not found passkey, display message "Wrong Confirmation code" 
	else 
	{
		$_SESSION['message'] = "Wrong confirmation code!";
		header('Location: verify.php');
	}

	// if successfully moved data from table"temp_members_db" to table "registered_members" displays message "Your account has been activated" and don't forget to delete confirmation code from table "temp_members_db"
}
?>